define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'project_checklog/index' + location.search,
                    // add_url: 'project_checklog/add',
                    // edit_url: 'project_checklog/edit',
                    // del_url: 'project_checklog/del',
                    // multi_url: 'project_checklog/multi',
                    table: 'project_checklog',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        // {field: 'project_pno', title: __('Project_pno')},
                        {field: 'project_name', title: __('Project_name')},
                        // {field: 'operator_id', title: __('Operator_id')},
                        {field: 'operator_nickname', title: __('Operator_nickname')},
                        {field: 'operate_field_label', title: __('字段')},
                        {field: 'operate_desc', title: __('Operate_desc')},
                        // {field: 'operate_field', title: __('Operate_field')},
                        {field: 'operate_original_value', title: __('Operate_original_value')},
                        {field: 'operate_value', title: __('Operate_value')},
                        {field: 'operate_info', title: __('操作备注')},
                        {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'update_time', title: __('Update_time'), operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
                        // {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        fieldlog: function() {
            Table.api.init({
                extend: {
                    index_url: 'project_checklog/fieldlog' + location.search,
                    // add_url: 'project_checklog/add',
                    // edit_url: 'project_checklog/edit',
                    // del_url: 'project_checklog/del',
                    // multi_url: 'project_checklog/multi',
                    table: 'project_checklog',
                }
            });

            var table = $("#table");
            console.log(Config.operate_field);
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'id',
                search: false,
                showExport: false,
                showToggle: false,
                showColumns: false,
                commonSearch: true,
                searchFormVisible: true,
                showSearch: true,
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id'), operate:false},
                        // {field: 'project_name', title: __('Project_name')},
                        {field: 'operator_nickname', title: __('Operator_nickname'), operate:'like'},
                        // {field: 'operate_field_label', title: __('Operate_field')},
                        {field: 'operate_original_value', title: __('Operate_original_value'), operate:false},
                        {field: 'operate_value', title: __('Operate_value'), operate:false},
                        {field: 'operate_desc', title: __('Operate_desc'),operate:false},
                        {field: 'operate_info', title: __('操作备注'),operate:false},
                        {field: 'create_time', title: __('操作时间'), operate:'RANGE', addclass:'datetimerange', formatter:Table.api.formatter.datetime,datetimeFormat:'YYYY-MM-DD'},
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});